

"""
print(1/0)
Traceback (most recent call last):
  File "/home/dan/Desktop/python_code/learning/012_try_except.py", line 2, in <module>
    print(1/0)
ZeroDivisionError: division by zero

"""




try:
    print(1/0)
except ZeroDivisionError:   # 捕获异常
    print("不能除以零")
else:
    print("else ?")


try:
    with open('011_file2.txt', 'r') as f:
        print(f.read())
except FileNotFoundError:
    print('file not found')
else:
    print('file found')
finally:    # 无论怎样 都会执行
    print('all done')
